package com.zhiyou100.review.day014.mycalendar;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.CharsetUtil;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @packageName: MyCalender
 * @className: com.zhiyou100.review.day014.mycalendar
 * @Description: TODO 日历类 测试
 * @author: yang
 * @date: 6/22/20
 */
public class MyCalender {
    public static void main(String[] args) {
        long[] a = {
                1, 34, 32, 4, 234, 25, 12, 4, 234, 12, 3432,
        };

        String s = Convert.toStr(a);
        // 转为 字符串
        System.out.println(s);


        String[] str = {"1", "2", "3", "4", "5"};
        Integer[] integers = Convert.toIntArray(str);
        // 转为 int 数组
        System.out.println(Convert.toStr(integers));

        String dateStr = "2020-05-06";
        Date date = Convert.toDate(dateStr);
        // 转为 日期类
        System.out.println(Convert.toStr(date));

        Object[] obj = {"a", "你好", "", 1};
        List<?> objects = Convert.toList(obj);
        // 转换 为 集合
        for (Object object : objects) {
            System.out.println(object);
        }


        String hexStr = "我是一个小小的可爱的字符串";
        String s1 = Convert.toHex(hexStr, CharsetUtil.CHARSET_UTF_8);
        // 字符串 转 16进制(Hex)
        System.out.println(s1);

        String s2 = Convert.hexToStr(s1, CharsetUtil.CHARSET_UTF_8);
        // 16进制 转 字符串
        System.out.println(s2);


        double d1 = 12346.21;
        // 金额大小写转换
        String s3 = Convert.digitToChinese(d1);
        System.out.println(s3);


    }


}

abstract class BaseTestCalendar {
    void hehe() {
        System.out.println("hello");
    }

    static BaseTestCalendar getInstance() {
        return new BaseTestCalendar() {
        };
    }


}

class TestCalendar {
    static void toDayList() {
        // 使用calendar计算从2010年1月1日开始 三天打鱼两天晒网  今天在干啥
        Calendar today = Calendar.getInstance();
        Calendar yesterday = (Calendar) today.clone();
        // 昨天
        yesterday.set(2010, 1, 1);
        // 设置时间为 2010-1-1

        long l = today.getTimeInMillis() - yesterday.getTimeInMillis();
        // 获取 毫秒值的差
        long l1 = Convert.convertTime(l, TimeUnit.MILLISECONDS, TimeUnit.DAYS);
        // 毫秒值转为 天

        // ateSum % 5，结果的余数若为0，1，2则在打渔，若为3，4在是在晒网。
        boolean one = l1 % 5 == 3;
        boolean two = l1 % 5 == 4;
        if (one || two) {
            // 打鱼
            System.out.println("在打渔");
        } else {
            // 晒网
            System.out.println("在晒网");

        }
    }

    public static void main(String[] args) {
        toDayList();


//        String s = new AA().toString();
//        String s1 = new Aa().toString();
        // Exception in thread "main" java.lang.NoClassDefFoundError: com/zhiyou100/review/day014/mycalendar/AA (wrong name: com/zhiyou100/review/day014/mycalendar/Aa)
//        System.out.println(s);
//        System.out.println(s1);

    }
}

class Aa {
    public Aa() {
    }

    @Override
    public String toString() {
        return "a";
    }
}

class AA {
    @Override
    public String toString() {
        return "A";
    }
}
